home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Forms Misc / only-one-field.izs < prev    next >
Text File  |  2005-09-28  |  3KB  |  131 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Only One Field
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>The visitor must fill in either one of two fields, their name or email address. If they click in either box the other box's value is erased. Ensures that when the form is submitted only one field contains a value. Also contains validation that makes sure both fields are not empty. <!/DESCRIPTION> 
  7.  
  8. <!CATEGORY>Forms<!/CATEGORY>
  9.  
  10. <!SCRIPT>
  11. <!-- START OF SCRIPT -->
  12.  
  13.  
  14. <!-- HOW TO INSTALL ONLY ONE FIELD:
  15.  
  16.   1.  Copy code into the HEAD section of document
  17.   2.  Put last coding into the BODY section of document  -->
  18.  
  19. <!-- STEP ONE: Add code into HEAD section of document  -->
  20.  
  21. <HEAD>
  22.  
  23. <SCRIPT LANGUAGE="JavaScript">
  24.  
  25.  
  26. <!-- Begin
  27. function checkFields() {
  28. name = document.submitform.name.value;
  29. email = document.submitform.email.value;
  30.  
  31. if ((name == "") && (email == "") ) {
  32. alert("Please enter your name or your email address.");
  33. return false;
  34. }
  35. else return true;
  36. }
  37. //  End -->
  38. </script>
  39. </HEAD>
  40.  
  41. <!-- STEP TWO: Add code into BODY section of document  -->
  42.  
  43. <BODY>
  44.  
  45. <center>
  46. <form action="http://www.your-web-site-address-here.com/script.cgi" name=submitform onSubmit="return checkFields()">
  47.  
  48. Please enter your name or your email address.<br><br>
  49. <table border=0>
  50. <tr>
  51. <td align=center>Name</td>
  52. <td> </td>
  53. <td align=center>Email</td>
  54. </tr>
  55. <tr>
  56. <td align=center><input type=text name=name value="" onFocus="document.submitform.email.value='';" size=10></td>
  57. <td align=center>Or...</td>
  58. <td align=center><input type=text name=email value="" onFocus="document.submitform.name.value='';" size=10></td>
  59. </tr>
  60. <tr>
  61. <td colspan=3 align=center><input type=submit value="Submit!"></td>
  62. </tr>
  63. </table>
  64. </form>
  65. </center>
  66.  
  67. <!-- END OF SCRIPT -->
  68. <!/SCRIPT>
  69.  
  70. <!PREVIEW>
  71. <!-- START OF SCRIPT -->
  72.  
  73.  
  74.  
  75. <!-- HOW TO INSTALL ONLY ONE FIELD:
  76.  
  77.   1.  Copy code into the HEAD section of document
  78.   2.  Put last coding into the BODY section of document  -->
  79.  
  80. <!-- STEP ONE: Add code into HEAD section of document  -->
  81.  
  82. <HEAD>
  83.  
  84. <SCRIPT LANGUAGE="JavaScript">
  85.  
  86.  
  87. <!-- Begin
  88. function checkFields() {
  89. name = document.submitform.name.value;
  90. email = document.submitform.email.value;
  91.  
  92. if ((name == "") && (email == "") ) {
  93. alert("Please enter your name or your email address.");
  94. return false;
  95. }
  96. else return true;
  97. }
  98. //  End -->
  99. </script>
  100. </HEAD>
  101.  
  102. <!-- STEP TWO: Add code into BODY section of document  -->
  103.  
  104. <BODY>
  105.  
  106. <center>
  107. <form action="http://www.your-web-site-address-here.com/script.cgi" name=submitform onSubmit="return checkFields()">
  108.  
  109. Please enter your name or your email address.<br><br>
  110. <table border=0>
  111. <tr>
  112. <td align=center>Name</td>
  113. <td> </td>
  114. <td align=center>Email</td>
  115. </tr>
  116. <tr>
  117. <td align=center><input type=text name=name value="" onFocus="document.submitform.email.value='';" size=10></td>
  118. <td align=center>Or...</td>
  119. <td align=center><input type=text name=email value="" onFocus="document.submitform.name.value='';" size=10></td>
  120. </tr>
  121. <tr>
  122. <td colspan=3 align=center><input type=submit value="Submit!"></td>
  123. </tr>
  124. </table>
  125. </form>
  126. </center>
  127. <!-- END OF SCRIPT -->
  128. <!/PREVIEW>
  129.  
  130. <!RELATED>NONE<!/RELATED>
  131.